<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.joinhawaii.admin.product.*" %>
<%

	HashList code111	= CommonUtil.getCodeList("111");	//선택관광구분
	HashList code113	= CommonUtil.getCodeList("113");	//선택관광구분
	HashList codeUseYn	= CommonUtil.getCodeList("use_yn");	//선택관광구분

	String job_type		= StringUtil.nvl(request.getParameter("job_type"),"U");
	String enjoy_id		= StringUtil.nvl(request.getParameter("enjoy_id"));

	HashMap infos = new HashMap();
	infos.put("enjoy_id",	enjoy_id);

	ProductDAO dao 		= new ProductDAO();
	HashList list 		= dao.selectEnjoyList(infos);
	HashList priceList 	= dao.selectEnjoyPriceList(infos);


%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>조인하와이</title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>
	<script type="text/javascript" src="/js/ajaxfileupload.js"></script>
	<script type="text/javascript" src="/SE2.3.1.O9858/js/HuskyEZCreator.js" charset="utf-8"></script>

	<script type="text/javascript">
	var oEditors = [];

	$(document).ready(function() {

		cfInitSE("enjoy_include");
		cfInitSE("enjoy_info");
		cfInitSE("enjoy_detail");
		cfInitSE("enjoy_schedule");


		/* 탭 클릭 */
		$('li', '#tabs').click(function(){
		    $('.on', '#tabs').removeClass('on').addClass('off');
		    $(this).addClass('on');

			$('#tabs-1:not(.hidden),#tabs-2:not(.hidden),#tabs-3:not(.hidden)').addClass('hidden');
			$('#tabs-'+$(this).attr('code')).removeClass('hidden');

			if ($(this).attr('code') == '3') {
				cfInitSE("enjoy_pic");
			}
		});

		$('#list').find('input').change(function() {
			$(this).closest('tr').find('input[name="list.job_type"][value!="C"]').val('U');
		});


	});


	function fnSave() {
		if (confirm(MSG_<%=job_type%>)) {
			// 에디터의 내용이 textarea에 적용됩니다.
			oEditors.getById["enjoy_include"].exec("UPDATE_CONTENTS_FIELD", []);
			oEditors.getById["enjoy_info"].exec("UPDATE_CONTENTS_FIELD", []);
			oEditors.getById["enjoy_detail"].exec("UPDATE_CONTENTS_FIELD", []);
			oEditors.getById["enjoy_schedule"].exec("UPDATE_CONTENTS_FIELD", []);

			$('#saveForm').attr('action', './enjoySave.do');
			$('#saveForm').submit();
		}
	}

	function fnPicSave() {
		oEditors.getById["enjoy_pic"].exec("UPDATE_CONTENTS_FIELD", []);
		$('#picSaveForm').submit();
	}

	function fnDelete() {
		if (confirm(MSG_D)) {
			$('#job_type').val('D');
			$('#saveForm').attr('action', './enjoySave.do');
			$('#saveForm').submit();
		}
	}



	function fnUpdatePrice() {
		if (confirm(MSG_SAVE))
		{
			$('#priceSaveForm').attr('action', './enjoyPriceSave.do');
			$('#priceSaveForm').submit();
		}
	}


	function fnAddRow() {

		var txt = '<tr><td><input type="hidden" name="list.job_type" value="C"  />'
				+ '<input type="hidden" name="list.enjoy_id" value="<%= enjoy_id %>" />'
				+ '<input type="hidden" name="list.price_id" value=""  />'
				+ '<input type="checkbox" name="chk" value=""/></td>'
				+ '<td><input type="text" name="list.price_name" value="" class="wmax"/></td>'
				+ '<td><input type="text" name="list.adult_cost" value="" class="wmax r"/></td>'
				+ '<td><input type="text" name="list.adult_sales_price" value="" class="wmax r"/></td>'
				+ '<td><input type="text" name="list.adult_b2b_price" value="" class="wmax r"/></td>'
				+ '<td><input type="text" name="list.kid_cost" value="" class="wmax r"/></td>'
				+ '<td><input type="text" name="list.kid_sales_price" value="" class="wmax r"/></td>'
				+ '<td class="brx"><input type="text" name="list.kid_b2b_price" value="" class="wmax r"/></td></tr>';

		$("#list").append(txt);
	}

	function fnDeleteRow() {
		var chks = $('input:checkbox[name="chk"]:checked');
		for (var i = 0; i < chks.length; i++) {
			$(chks[i]).closest('tr').find('input[name="list.job_type"]').val('D');
			$(chks[i]).closest('tr').hide();
		}
	}

	</script>
</head>
<body>
<div id="wrap">
	<div id="top">
		<%@ include file="/admin/include/top.jsp" %>
	</div>
	<div id="page">
		<div id="menu">
			<%@ include file="/admin/include/leftMenu.jsp" %>
		</div>
		<div id="contents">
			<div class="menu_title">
				<h1>선택관광</h1>
				<p>관리자 > 상품관리 > <b>선택관광</b></p>
			</div>
			<div class="clear line_01"></div>



			<ul id="tabs" class="tab_01 mt15">
			    <li class="on"  code="1"><p>1. 기본사항</p></li>
		<%	if ("U".equals(job_type)) { %>
			    <li class="off" code="2"><p>2. 상품가격</p></li>
			    <li class="off" code="3"><p>3. 참고사진</p></li>
		<%	} %>
			</ul>


			<div id="tabs-1" class="mt15">

				<form id="saveForm" method="post" action="" enctype="multipart/form-data">
				<input type="hidden" name="job_type" id="job_type" value="<%= job_type %>"/>
				<input type="hidden" name="enjoy_id" value="<%= list.get("enjoy_id", 0) %>"/>

				<table cellpadding="0" cellspacing="0" class="table_01 mt5">
				<colgroup>
					<col width="100px"/>
					<col width="380px"/>
					<col width="100px"/>
					<col/>
				</colgroup>
				<tbody>
					<tr>
						<th><p>선택관광명</p></th>
						<td colspan="3" class="brx">
							<input type="text" name="enjoy_name" value="<%= list.get("enjoy_name", 0) %>"  maxlength="255" class="wmax"/>
						</td>
					</tr>
					<tr>
						<th><p>선택관광구분</p></th>
						<td>
							<select name="enjoy_gubn">
							<%= StringUtil.makeOption(code113, list.get("enjoy_gubn", 0)) %>
						  	</select>
						</td>
						<th><p>회사명</p></th>
						<td class="brx">
		        			<select name="company_code">
							<%= StringUtil.makeOption(code111, list.get("company_code", 0)) %>
						  	</select>
						</td>
					</tr>
					<tr>
						<th><p>가격여부</p></th>
						<td>
							<input type="radio" name="price_yn" value="Y"  <%= StringUtil.checked("Y",list.get("price_yn",0)) %>/>Y &nbsp;&nbsp;&nbsp;
							<input type="radio" name="price_yn" value="N"  <%= StringUtil.checked("N",list.get("price_yn",0)) %>/>N
	        			</td>
						<th><p>추천여부</p></th>
						<td class="brx">
							<input type="checkbox" name="est_yn" value="Y" <%= StringUtil.checked("Y",list.get("est_yn",0)) %>/> 추천
							<input type="checkbox" name="main_yn" value="Y" <%= StringUtil.checked("Y",list.get("main_yn",0)) %>/> 특가상품
	        			</td>
					</tr>
					<tr>
						<th><p>장소</p></th>
						<td>
							<input type="text" name="location" value="<%= list.get("location", 0) %>"  maxlength="255" class="wmax"/>
						</td>
						<th><p>휴무일</p></th>
						<td class="brx">
							<input type="text" name="enjoy_exclude" value="<%= list.get("enjoy_exclude", 0) %>"  maxlength="255" class="wmax"/>
						</td>
					</tr>
					<tr>
						<th><p>소요시간</p></th>
						<td>
							<input type="text" name="take_time" value="<%= list.get("take_time", 0) %>"  maxlength="255" class="wmax"/>
						</td>
						<th><p>소아기준</p></th>
						<td class="brx">
							<input type="text" name="kid_cond" value="<%= list.get("kid_cond", 0) %>"  maxlength="255" class="wmax"/>
						</td>
					</tr>
					<tr>
						<th><p>이동수단</p></th>
						<td>
							<input type="text" name="transfer" value="<%= list.get("transfer", 0) %>"  maxlength="255" class="wmax"/>
						</td>
						<th><p>취소변경</p></th>
						<td class="brx">
							<input type="text" name="use_limit" value="<%= list.get("use_limit", 0) %>"  maxlength="255" class="wmax"/>
						</td>
					</tr>
					<tr>
						<th><p>사용유무</p></th>
						<td>
							<%= StringUtil.makeRadio(codeUseYn, "use_yn", list.get("use_yn", 0)) %>
						</td>
						<th><p>정렬순서</p></th>
						<td class="brx">
							<input type="text" name="sort_flag" value="<%= list.get("sort_flag", 0) %>"  maxlength="3" class="wmax"/>
						</td>
					</tr>
					<tr>
						<th><p>대표사진</p></th>
						<td>
						<%	if ("C".equals(job_type)) { %>
								등록후 업로드
						<%	} else { %>
							<input type="file" name="img_path_00" value="" class="w200" />
			        		<a href="<%= list.get("img_path_00",0) %>" target="_blank"><%= list.get("img_path_00",0) %></a>
			        	<%	} %>
						</td>
						<th><p>업체바우처</p></th>
						<td class="brx">
							<%= StringUtil.makeRadio(codeUseYn, "voucher_yn", list.get("voucher_yn", 0)) %>
						</td>
					</tr>
					<tr>
						<th><p>상품안내</p></th>
						<td colspan="3" class="brx">
							<textarea name="enjoy_detail" id="enjoy_detail" style="width:860px; height:200px"><%= list.get("enjoy_detail", 0) %></textarea>
						</td>
					</tr>
					<tr>
						<th><p>상품정보</p></th>
						<td colspan="3" class="brx">
							<textarea name="enjoy_info" id="enjoy_info" style="width:860px; height:200px"><%= list.get("enjoy_info", 0) %></textarea>
						</td>
					</tr>
					<tr>
						<th><p>세부일정 및 코스</p></th>
						<td colspan="3" class="brx">
							<textarea name="enjoy_schedule" id="enjoy_schedule" style="width:860px; height:200px"><%= list.get("enjoy_schedule", 0) %></textarea>
						</td>
					</tr>
					<tr>
						<th><p>안내및주의사항(바우처용)</p></th>
						<td colspan="3" class="brx">
							<textarea name="enjoy_include" id="enjoy_include" style="width:860px; height:200px"><%= list.get("enjoy_include", 0) %></textarea>
						</td>
					</tr>
				</tbody>
				</table>

				<div class="mt20 mb10 c">
					<a href="./enjoyList.jsp"><img src="/images/admin/btn_list.gif"/></a>
			<%	if ("U".equals(job_type)) { %>
					<a href="#nohref" onclick="fnSave()"><img src="/images/admin/btn_update.gif" /></a>
					<a href="#nohref" onclick="fnDelete()"><img src="/images/admin/btn_delete.gif" /></a>
			<%	} else if ("C".equals(job_type)) { %>
					<a href="#nohref" onclick="fnSave()"><img src="/images/admin/btn_register.gif" /></a>
			<%	} %>
				</div>

				</form>

			</div>



			<!-- 상품가격 -->
			<div id="tabs-2" class="hidden mt15">

				<form id="priceSaveForm" method="post" action="./enjoyPriceSave.do">
				<input type="hidden" name="enjoy_id" id="enjoy_id" value="<%= enjoy_id %>"/>

				<table cellpadding="0" cellspacing="0" class="table_03 mt5">
				<colgroup>
					<col width="40px"/>
					<col width="300px" />
					<col width="80px"/>
					<col width="80px"/>
					<col width="80px"/>
					<col width="80px"/>
					<col width="80px"/>
					<col width="80px"/>
				</colgroup>
				<tbody id="list">
					<tr>
						<th rowspan="2"><p><input type="checkbox" name="chkAll" id="chkAll"/></p></th>
						<th rowspan="2"><p>상품명</p></th>
						<th colspan="3"><p>어른</p></th>
						<th colspan="3" class="brx"><p>소아</p></th>
					</tr>
					<tr>
						<th><p>cost</p></th>
						<th><p>sales</p></th>
						<th><p>b2b</p></th>
						<th><p>cost</p></th>
						<th><p>sales</p></th>
						<th class="brx"><p>b2b</p></th>
					</tr>
			<%	for (int i = 0; i < priceList.size(); i++) { %>
					<tr>
						<td>
							<input type="hidden" name="list.job_type" value="X" class="w20" />
							<input type="hidden" name="list.enjoy_id" value="<%= priceList.get("enjoy_id", i) %>" />
							<input type="hidden" name="list.price_id" value="<%= priceList.get("price_id", i) %>"  />
							<input type="checkbox" name="chk" value=""/>
						</td>
						<td><input type="text" name="list.price_name" value="<%= priceList.get("price_name",i) %>" class="wmax"/></td>
						<td><input type="text" name="list.adult_cost" value="<%= priceList.get("adult_cost",i) %>" class="wmax r"/></td>
						<td><input type="text" name="list.adult_sales_price" value="<%= priceList.get("adult_sales_price",i) %>" class="wmax r"/></td>
						<td><input type="text" name="list.adult_b2b_price" value="<%= priceList.get("adult_b2b_price",i) %>" class="wmax r"/></td>
						<td><input type="text" name="list.kid_cost" value="<%= priceList.get("kid_cost",i) %>" class="wmax r"/></td>
						<td><input type="text" name="list.kid_sales_price" value="<%= priceList.get("kid_sales_price",i) %>" class="wmax r"/></td>
						<td class="brx"><input type="text" name="list.kid_b2b_price" value="<%= priceList.get("kid_b2b_price",i) %>" class="wmax r"/></td>
					</tr>
			<%	} %>
				</tbody>
				</table>

				<div class="mt20 mb10 c">
					<a href="./enjoyList.jsp"><img src="/images/admin/btn_list.gif"/></a>
					<img src="/images/admin/btn_addrow.gif" class="pointer" onclick="fnAddRow()"/>
					<img src="/images/admin/btn_delrow.gif" class="pointer" onclick="fnDeleteRow()"/>
					<a href="#nohref" onclick="fnUpdatePrice()"><img src="/images/admin/btn_save.gif" /></a>
				</div>

				</form>
			</div>


			<!-- 참고사진 -->
			<div id="tabs-3" class="hidden mt15">
				<form id="picSaveForm" method="post" action="./picSave.do" enctype="multipart/form-data">
				<input type="hidden" name="pic_name" id="pic_name" value="enjoy"/>
				<input type="hidden" name="pic_id" value="<%= list.get("enjoy_id", 0) %>"/>
				<div class="ml10 mr10">
					<textarea name="enjoy_pic" id="enjoy_pic" style="width:100%; height:800px" ><%= list.get("enjoy_pic", 0) %></textarea>
				</div>
				<div class="mt20 mb10 c">
					<a href="./enjoyList.jsp"><img src="/images/admin/btn_list.gif"/></a>
					<a href="#nohref" onclick="fnPicSave()"><img src="/images/admin/btn_update.gif" /></a>
				</div>
				</form>
			</div>




		</div>
	</div>
</div>

</body>
</html>
